package com.app.freshmenapp;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

import com.app.freshmenapp.R;
import com.app.freshmenapp.bean.MyBean;

import java.util.List;

/**
 * Created by Administrator on 2020/10/16.
 */

class MyAdapter extends BaseAdapter {
    List<MyBean.ListBean> list;
    Context context;

    public MyAdapter(List<MyBean.ListBean> list, Context context) {
        this.list = list;
        this.context = context;
    }

    @Override
    public int getCount() {
        return list.size();
    }

    @Override
    public Object getItem(int position) {
        return list.get(position);
    }

    @Override
    public long getItemId(int position) {
        return position;
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        View view = LayoutInflater.from(context).inflate(R.layout.item_listview, parent, false);
        TextView textView = (TextView) view.findViewById(R.id.textview);
        // 把DataBean的数据从List里面取出来。
           MyBean.ListBean listBean = list.get(position);
       //  获取当前项的数据中的某个属性的值，将其设置为文本框控件的属性，完成数据的呈现。
             textView.setText(listBean.getTitle()+"");
        // 返回填充了内容的项视图对象。
        return view;
    }
}

